//引入拦截器中axios实例，在这里发送医院列表的请求
import { request } from "@/utils/http";

//引入请求数据的类型
import {
    hospitalListSearchParamsType,
    hospitalListReturnType,
    getProvinceReturnType,
    hospitalListItemsType,
    hospitalDetailReturnType,
    hosDepartmentReturnType,
    hosScheduleParamType,
    hosScheduleReturnType,
    getDoctorSchedulParamType,
    getDoctorSchedulReturnType
} from './model/hospitalListType'


//需要请求的数据 page,limit,hoscode,hosname,hostype,provinceCode,cityCode,districtCode,status
//后面的数据可以用一个对象传递
//1、进入医院列表自动获取列表请求,传递参数
export const getHosListRequest = (page:number,limit:number,searchParams:hospitalListSearchParamsType)=>{

    return request.get<any,hospitalListReturnType>(`/admin/hosp/hospital/${page}/${limit}`,{
        params:searchParams
    })
}


//2、进入列表获取省份的api
export const getProvinceRequest = ()=>{

    return request.get<any,getProvinceReturnType>('/admin/cmn/dict/findByDictCode/province')
}

//3，获取市列表的api
export const getCityOrDistrictRequest=(value:string)=>{
    //子级菜单获取上级菜单的id，参数时上级菜单的id
    return request.get<any,getProvinceReturnType>(`/admin/cmn/dict/findByParentId/${value}`)
}

//4、查看医院详情的请求
export const getHosDetailsRequest = (id:string)=>{
    
    return request.get<any,hospitalDetailReturnType>(`/admin/hosp/hospital/show/${id}`)
}

//5、修改状态的请求
export const getChangeStatusRequest = (id: string, status: 0|1)=>{
    return request.get<any,null>(`/admin/hosp/hospital/updateStatus/${id}/${status}`)
}
//6、获取医院排班的树形结构请求
export const hosDepartmentRequest = (hoscode:string)=>{
    return request.get<any,hosDepartmentReturnType>(`/admin/hosp/department/${hoscode}`)
}

//7、获取医院排班规则的请求
export const hosScheduleRuleRequest = ({page,limit,hoscode,depcode}:hosScheduleParamType)=>{
    return request.get<any,hosScheduleReturnType>(`/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`)
}

//8、获取医生排班
export const getDoctorSchedulRequest =({hoscode,depcode,workDate}:getDoctorSchedulParamType)=>{
    return request.get<any,getDoctorSchedulReturnType>(`/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`)
}